package cn.bgs.controller;

import cn.bgs.req.LoginReq;
import cn.bgs.res.Result;
import cn.bgs.service.ManagerService;
import cn.bgs.utils.R;
import cn.bgs.vo.JwtManagerVo;
import cn.bgs.vo.loginVo;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping("/manager")
public class loginController {

    @Resource
    private ManagerService managerService;
    //登录
    @RequestMapping("/login")
    public R  login(@RequestBody LoginReq loginReq){
        System.out.println("----:"+loginReq);
        Result<loginVo> login = managerService.login(loginReq);
        System.out.println("login::::"+login);
        return R.ok().data("login",login).code(200).message("登陆成功");
    }
    @PostMapping("/updateUser")
    public R updateUser(@RequestBody loginVo user){

        int i=managerService.updateUser(user);
        if(i==1){
            int q=managerService.updateOperat(user);
            return R.ok();
        }else {
            return R.error();
        }
    }

}
